<template>
	<view class="container">
		<uni-nav-bar :fixed="true" :border="false" :statusBar="true" backgroundColor="rgba(0, 0, 0, 1)"></uni-nav-bar>
		<view class="" v-if="orderList.length>0">
			<view class="order-item" v-for="(order, index) in orderList" :key="index" @click="goPage(order)">
				<!-- 订单标题和交易状态 -->
				<view class="order-header">
					
				</view>

				<view class="order-box">
					<view class="order-box-l">
						<view class="order-title">{{ order.goods.name }}</view>
						<view class="order-details">
							<view class="detail-text">{{ order.ticketDate }}</view>
						</view>
						<!-- 订单详情规格 -->
						<view class="order-details">
							<text class="detail-text">{{ order.goods.region }}</text>
						</view>

						<!-- 价格、数量、运费 -->
						<view class="order-info">
							<text class="price"><text class="price-icon">￥</text> {{ order.price }}</text>
							<text class="quantity"> / 共 {{ order.ticketAmount }} 张</text>
							<!-- <text class="shipping">（含运费: {{ order.shipping }}）</text> -->
						</view>
					</view>

					<!-- 订单图片 -->
					<view class="order-image">
						<view class="order-status">{{ statusFun(order.ticketStatus) }}</view>
						<image :src="host+order.goods.icon" mode="aspectFill" class="image"></image>
					</view>
				</view>

			</view>
			<uLoadMore v-if="orderList.length>=4" :status="more"></uLoadMore>
		</view>
		<sunui-template v-else title="暂无票夹信息~" />

	</view>
</template>

<script>
	import uLoadMore from '@/components/uni-load-more/uni-load-more.vue'
	export default {
			components: {
				uLoadMore,
			},
		data() {

			return {
				host: this.$apiFun.host,
				more: 'more', //noMore more loading
				orderList: [
					// {
					//   title: '五月天 LIFE[人生无限公司]世五月天',
					//   status: '待使用',
					//   details: '佛山: 体育馆, 尺寸: L',
					//   price: '100.00',
					//   quantity: 2,
					//   shipping: 10,
					//   image: 'https://qcloud.dpfile.com/pc/As5tfeAJ3bNz0EHihrTx4WJThVNQ8kb0ttUPBSmOWSUDY_ZFhBScrG7sKiYM3WjS.jpg'
					// },
					// {
					//   title: '[A CLASSIC TOUR 学友·经典]世界巡回演唱会',
					//   status: '待使用',
					//   details: '规格: 白色, 尺寸: M',
					//   price: '200.00',
					//   quantity: 1,
					//   shipping: 15,
					//   image: 'https://qcloud.dpfile.com/pc/As5tfeAJ3bNz0EHihrTx4WJThVNQ8kb0ttUPBSmOWSUDY_ZFhBScrG7sKiYM3WjS.jpg'
					// },
					// 更多订单...
				],

				paramObj: {
					page: 1,
					pageSize: 10,
					haveTicket:true,
					status:'',
					pageEntry:2,//时,0:待出票 1:已出票 2:已完成
				},
			};
		},
		async onLoad() {
			this.init()
		},
		methods: {
			goPage(item) {
				uni.navigateTo({
					url: '/page_up/detail?obj=' + encodeURIComponent(JSON.stringify(item))
				})
			},
			async init() {
				this.more = 'loading'
				let {
					datas
				} = await this.$apiFun.getApi(
					this.$api.orderListApi,
					this.paramObj
				)
				uni.hideLoading()
					console.log('this.orderList',datas)
				if (datas.length > 0) {
					this.orderList = this.orderList.concat(datas)
					this.more = 'more'
				} else {
					this.more = 'noMore'
				}
			},
			statusFun(val){
				// ticketStatus  出票状态(0:待出票 1:已出票 2:已完成)
				let text = ''
					switch(val){
						case 0:
						text = '待出票'
						break;
						case 1:
						text = '已出票'
						break;
						case 2:
						text = '已完成'
						break;
					}
					return text
			},

		},

		onReachBottom() {
			this.paramObj.page++
			this.init()
		},
	};
</script>
<style>
	page {
		height: 100%;
		background: #000000;
	}
</style>
<style lang="less" scoped>
	page {

		background: #000000;
	}

	.container {
		padding: 20rpx 20rpx 50rpx;
	}

	.order-item {
		// background-color: rgba(255, 255, 255, 0.1);
		color: rgba(255, 255, 255, 1);
		margin-bottom: 20rpx;
		padding: 40rpx 30rpx;
		// border: 1rpx solid #ccc;
		border-radius: 10rpx;
		box-sizing: border-box;
	}

	.order-header {
		display: flex;
		justify-content: space-between;
		// align-items: center;
		margin-bottom: 10rpx;
	}

	

	

	.order-box {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		.order-box-l{
			.order-title {
				font-size: 30rpx;
				width: 500rpx;
				height: 85rpx;
				color: rgba(255, 255, 255, 1);
				display: -webkit-box;
				-webkit-line-clamp: 2;
				/* 限制文本显示为2行 */
				-webkit-box-orient: vertical;
				/* 垂直排列盒子 */
				overflow: hidden;
				/* 隐藏超出部分 */
				text-overflow: ellipsis;
			}
		}
	}

	.order-details {
		margin: 10rpx auto;
	}

	.detail-text-l {}

	.detail-text {
		font-size: 28rpx;
		color: rgba(255, 255, 255, .7);
	}

	.order-info {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 10rpx;
		width: 200rpx;
	}

	.price {
		font-size: 40rpx;
		font-weight: bold;
		margin-right: 10rpx;
		color: rgba(255, 255, 255, .7);

		.price-icon {
			font-size: 20rpx;
		}

	}

	.quantity,
	.shipping {
		font-size: 28rpx;
		color: rgba(255, 255, 255, .7);
	}

	.order-image {
		width: 130rpx;
		.order-status {
			text-align: right;
			font-size: 28rpx;
			margin:0 auto 20rpx;
		}
		.image {
			width: 130rpx;
			height: 200rpx;
			border-radius: 10rpx;
		}
	}
</style>